package com.qf.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
//环绕增强，必须调用原始方法
public class MyAroundAdvice implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        //调用原始方法
        try {
            System.out.println("前置增强");
            Object proceed = methodInvocation.proceed();
            System.out.println("后置增强");
            return proceed;
        } catch (Throwable e) {
            e.printStackTrace();
            System.out.println("异常增强");
        } finally {
            System.out.println("最终增强，无论有没有异常都增强");
        }
        return null;
    }
}
